package sort;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

/**
 * @author XY
 * @version 1.0
 * @date 2022/3/15 9:35
 * @Description
 */
public class Leet506 {

    public static String[] findRelativeRanks(int[] score) {
        int[] arr = Arrays.copyOf(score, score.length);
        Arrays.sort(arr);
        Map<String,String> map = new HashMap<>();
        int num  = 4;
        for (int i = arr.length - 1; i >= 0; i--) {
            if(i==arr.length - 1){
                map.put(arr[arr.length - 1]+"","Gold Medal");
            }else if(i==arr.length - 2){
                map.put(arr[arr.length - 2]+"","Silver Medal");
            }else if(i==arr.length - 3){
                map.put(arr[arr.length - 3]+"","Bronze Medal");
            }else{
                map.put(arr[i]+"",""+num++);
            }
        }
        String[] res = new String[score.length];
        for (int i = 0; i < score.length; i++) {
            res[i]=map.get(score[i]+"");
        }
        return res;
    }

    public static void main(String[] args) {
        int[] arr = {5,4,3,2,1};
        for (String relativeRank : findRelativeRanks(arr)) {
            System.out.println(relativeRank);
        }
    }

}
